
/**
 * @Author: 陈瑞鹏
 * @Date:   2023-01-11 15:35:34
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2023-01-11 17:39:42
 */

import netCtr from "../ctrs/netCtr";
import signCtr from "../ctrs/sign/signCtr";
import signEntity from "../ctrs/sign/signEntity";
import BaseGameComponent from "../libs/core/BaseGameComponent";
import { SceneManager } from "../libs/manager/SceneManager";

const { ccclass, property } = cc._decorator;

@ccclass

export default class signCom extends BaseGameComponent {
  @property({ type: cc.Label, tooltip: "标题" })
  titleTxt: cc.Label = null;

  @property({ type: cc.Label, tooltip: "内容" })
  descTxt: cc.Label = null;

  @property({ type: cc.Button, tooltip: "领取按钮" })
  btn: cc.Button = null;

  @property({ type: cc.Node, tooltip: "已领取节点" })
  isSignNode: cc.Node = null;

  private _signEny: signEntity = null;

  drawUi(data) {
    if (data) {
      this._signEny = data;
    }
    // console.log(data);
    this.titleTxt.string = this._signEny.name;
    this.descTxt.string = this._signEny.desc;
    if (this._signEny.isSign) {

      this.btn.interactable = false;
    } else {

      this.btn.interactable = true;
    }

    if (this._signEny.day == signCtr.ins.signDay) {
      this.isSignNode.active = true;
    } else {
      this.isSignNode.active = false;
    }
  }

  onLqClick() {
    if (!signCtr.ins.isSign && this._signEny.day == signCtr.ins.signDay) {
      netCtr.ins.sign();
    } else {
      SceneManager.getInstance().pushLayer("tipLayer", "今日已经签到！")
    }
  }
}